package com.zhangwei.touch;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

import com.zhangwei.touch.widget.MyRelativeLayout;
import com.zhangwei.touch.widget.MyView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "MainActivity";

    private MyView myView;
    private MyRelativeLayout rl;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myView = (MyView) this.findViewById(R.id.myView);
        rl = (MyRelativeLayout) this.findViewById(R.id.rl);
        myView.setOnClickListener(this);
        rl.setOnClickListener(this);


    }

    /**
     * 返回true  事件不向下分发
     *
     * @param ev
     * @return
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }

    /**
     * @param v
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl:
                Toast.makeText(MainActivity.this, "MyRelative", Toast.LENGTH_SHORT).show();
                break;
            case R.id.myView:
                break;

        }

    }
}
